import React, { Component } from 'react';
import Taro from '@tarojs/taro'
import { View, Image, Text, Button } from '@tarojs/components';
import { Popup } from '@antmjs/vantui';
import './index.scss'


interface RiskAssessmentPopupProps {
  showPopUP: boolean;
  onClose: Function;
  onSubmit: Function;
}

interface RiskAssessmentPopupState {

}



class RiskAssessmentPopup extends Component<RiskAssessmentPopupProps, any> {

  static defaultProps = {
    showPopUP: true,
    onSubmit: () => { },
    onClose: () => { }
  }

  onClose() {
    this.setState({ showPopUP: false });
    const { onClose } = this.props;
    onClose();
  }

  onSubmit() {
    this.setState({ showPopUP: false });
    const { onSubmit } = this.props;
    onSubmit();
  }

  constructor(props: RiskAssessmentPopupProps) {
    super(props);
    this.state = { showPopUP: false };
  }

  componentWillReceiveProps(nextProps, nextContext) {
    const { showPopUP } = nextProps;
    this.state = { showPopUP: showPopUP };
  }

  render() {
    const { showPopUP } = this.state;
    return (
      <Popup show={showPopUP} position='bottom' onClose={this.onClose.bind(this)}>
        <View className='risk-popup'>
          <Text className='tip'>风险评测提示</Text>
          <Text>本人已经了解并愿意遵守国家有关证券市场、基金市场管理的法律、法规、规章及相关业务规则；</Text>
          <Text>本人在此郑重承诺以上填写的内容真实、准确、完整，系本人以已独立、自主的意思表示。 </Text>
          <Text>若本人提供的信息发生任何重大变化，本人也将即时书面通知通知贵公司。</Text>
          <View className='button'>
            <Button className='button-item left-button' onClick={this.onClose.bind(this)}>取消</Button>
            <Button className='button-item right-button' onClick={this.onSubmit.bind(this)}>确定并提交</Button>
          </View>
        </View>

      </Popup>);
  }
}

export default RiskAssessmentPopup;
